<template>
<div class="login-bg">
  <div class="login-container">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm"
    label-width="100px" class="demo-ruleForm">

      <el-form-item label="用户名" prop="name">
        <el-input v-model="ruleForm.name"></el-input>
      </el-form-item>

      <el-form-item label="密码" prop="password">
        <el-input type="password" v-model="ruleForm.password"></el-input>
      </el-form-item>
    </el-form>

    <div class="containerRowCenter btn-box">
      <el-button type="primary" @click="loginRight">登录</el-button>
      <el-button @click="drawer = true" style="margin-left : 16px;">
        显示
      </el-button>

      <!-- drawer -->
      <el-drawer
        title="可选用户名" :visible.sync="drawer" :direction="direction">
        <div class="drawer-box">
          <div class="row-box">
          <el-row :gutter="12">
            <el-col :span="18">
              <el-card shadow="always">
                <div>管理员</div>
                <div>username: admin</div>
                <div>password: 随意</div>
              </el-card>
            </el-col>
          </el-row>
          </div>

<div class="row-box">
          <el-row :gutter="12">
            <el-col :span="18">
              <el-card shadow="always">
                <div>部门员工</div>
                <div>username: employee</div>
                <div>password: 随意</div>
              </el-card>
            </el-col>
          </el-row>

</div>

<div class="row-box">
          <el-row :gutter="12">
            <el-col :span="18">
              <el-card shadow="always">
                <div>游客</div>
                <div>username: visitor</div>
                <div>password: 随意</div>
              </el-card>
            </el-col>
          </el-row>
</div>
        </div>
      </el-drawer>
    </div>
  </div>
</div>
</template>

<script>
import { mapActions } from 'vuex';

export default {
  data() {
    return {
      ruleForm: {
        name: '',
        password: '',
      },
      rules: {
        name: [
          { required: true, message: '请输入用户名', trigger: 'blur' },
        ],
        password: [
          { required: true, message: '请输入密码', trigger: 'blur' },
        ],
      },
      drawer: false,
      direction: 'rtl',
    };
  },

  methods: {
    ...mapActions([
      'getLoginRight',
    ]),
    // 发送获得权限的请求
    loginRight() {
      this.getLoginRight(
        { name: this.$data.ruleForm.name, password: this.$data.ruleForm.password },
      );
    },
  },
};
</script>

<style>

</style>
